<style>
    #top_link_area .add-title,
    #top_link_area .add-url,
    #top_link_area .delete{float:left;_display:inline;margin-left:5px;}
    #top_link_area .delete{height:20px;width:16px;cursor:pointer;}
    #top_link_area .top-link-item{background-color:#E2E8EB;padding:5px 5px 3px;line-height:22px;margin:2px 0;}
    #add_top_link{cursor:pointer;}
</style>
<div class="tableform">
    关键词描述：<input name="hotkey" class="inputstyle" value="<{$setting.hotkey|default:'热门关键词'}>" /><br />
    <input type="button" id="add_top_link" value="添加关键词" />
    <ul id="top_link_area">

    </ul>
</div>

<script>
    var TopLinkTitle = new Array(<{foreach from=$setting.top_link_title item=title_item}> "<{$title_item}>", <{/foreach}>"end");
    TopLinkTitle.pop();
    var TopLinkUrl = new Array(<{foreach from=$setting.top_link_url item=url_item}>"<{$url_item}>",<{/foreach}>"end");
    TopLinkUrl.pop();
    var TopLink = new Hash(TopLinkUrl.associate(TopLinkTitle));
    function DelTopLink(item){
        item.getParent(".top-link-item").destroy();
    }
    function CreateTopLinkDom(DomHash){
        DomHash.each(function(v,k){
            var ActiveLi = new Element('li',{'class':'top-link-item clearfix','html':'<div class="add-title"> 文字：<input type="text" name="top_link_title[]" value="'+k+'"/> </div> <div class="add-url"> 链接地址：<input type="text" name="top_link_url[]" value="'+v+'"/> </div> <span class="delete" title="删除"></span>'}).inject('top_link_area');
            ActiveLi.getElement('.delete').addEvent('click',function(){
                DelTopLink(this);
            });
        });
    }
    CreateTopLinkDom(TopLink);
    var AddTopLink = $('add_top_link');
    AddTopLink.addEvent('click',function(){
        var ActiveLi = new Element('li',{'class':'top-link-item clearfix','html':'<div class="add-title"> 文字：<input type="text" name="top_link_title[]"/> </div> <div class="add-url"> 链接地址：<input type="text" name="top_link_url[]"/> </div> <span class="delete" title="删除"></span>'}).inject('top_link_area');
        ActiveLi.getElement('.delete').addEvent('click',function(){
            DelTopLink(this);
        });
    });
</script>
